<!DOCTYPE html>
<html lang="en">
<head>
	<title>个人中心</title>
	<#include "../common.ftl" />
    <link href="${ticket.contextPath}/static/common/css/datetimepicker/bootstrap-datetimepicker.min.css" rel="stylesheet" media="screen">

	<script type="text/javascript" src="${ticket.contextPath}/static/common/js/datetimepicker/bootstrap-datetimepicker.min.js" charset="UTF-8"></script>
    <script type="text/javascript" src="${ticket.contextPath}/static/common/js/datetimepicker/bootstrap-datetimepicker.zh-CN.js" charset="UTF-8"></script>
</head>
<body>
	<div class="container">
		<form id="userForm"  enctype="multipart/form-data"  style="max-width: 350px;margin: 0 auto;margin-top: 20%;">
            <input type="hidden" id="id" name="id" value="${(user.id)!}" />
			<div class="form-group">
				<label for="inputForAvatar">头像</label>
			    <a href="#" style="width: 80px;height: 80px;" >
			    	<img src="${ticket.contextPath}/static/admin/img/poster-about.jpg" alt="..." style="width: 80px;height: 80px;border-radius: 50%;">
			    	<p class="help-block">点击修改头像.</p>
			    </a>
			</div>
			<div class="form-group">
		    	<label for="inputForName">姓名</label>
			    <input type="text" class="form-control" id="inputForName" name="name" placeholder="姓名" value="${(user.name)!}">
			</div>
			<div class="form-group">
			    <label for="inputEmail">邮箱</label>
			    <input type="email" class="form-control" id="inputEmail" name="email" placeholder="Email" value="${(user.email)!}">
			</div>
			<div class="form-group">
		    	<#--<label for="inputForBirthday">生日</label>-->
                <label for="birthday">生日</label>
                <div class="input-group date form_datetime" data-date="1979-09-16T05:25:07Z" data-date-format="yyyy-mm-dd" data-link-field="birthday">
                    <input class="form-control" size="16" type="text" value="${(user.birthday?string("yyyy-MM-dd"))!}" readonly>
                    <span class="input-group-addon"><span class="glyphicon glyphicon-remove"></span></span>
                    <span class="input-group-addon"><span class="glyphicon glyphicon-th"></span></span>
                </div>
                <input type="hidden" id="birthday" name="birthday" value="${(user.birthday?string("yyyy-MM-dd"))!}" /><br/>
			    <#--<input type="date" class="form-control" id="inputForBirthday" placeholder="生日" >-->
			</div>
			<div class="form-group">
		    	<label for="inputForPhone">电话</label>
			    <input type="text" class="form-control" id="inputForPhone" name="phone" placeholder="电话" value="${(user.phone)!}">
			</div>
			<div class="checkbox">
			    <label class="radio-inline">
				  		<input type="radio" name="sex" id="boyOfSex" value="1" <#if !(user.sex)?? || user.sex == 1>checked="checked" </#if>> 男
				</label>
				<label class="radio-inline">
                        <input type="radio" name="sex" id="girlOfSex" value="2" <#if (user.sex)?? && user.sex == 2>checked="checked" </#if>> 女
				</label>
			</div>
            <button type="button" onclick="subForm()" class="btn btn-default">修改</button>
		</form>

	</div>
	<script>
    	 $(window.parent.document).find("#myiframe").load(function(){
            var main = $(window.parent.document).find("#myiframe").height();
            $("#bbb").height(main);
        });
         $('.form_datetime').datetimepicker({
             language:  'zh-CN',
             weekStart: 1,
             todayBtn:  1,
             autoclose: 1,
             todayHighlight: 1,
             startView: 2,
             forceParse: 0,
             minView: 2,
             showMeridian: 1
         });
        function subForm(){
        	var url="http://localhost/admin/user";
        	var form = $("#userForm");
        	var data = form.serialize()
            var formData = new FormData(document.getElementById("userForm"));   
		   $.ajax({ 
		    type:'POST', 
		    url:url,
               processData:false,
               contentType:false,
               cache: false,
		    data:formData, 
		    success:function(data){      
		      	alert('success');
		    },	
		    error:function(err){ 
				var ss = JSON.stringify(err)
		     	alert(ss)
		    }
		   })
        }
    </script>
</body>
</html>